package gaotingkunserialization;

import java.io.FileInputStream;
import java.io.ObjectInputStream;

public class Deserialization {
    public static void main(String[] args) {
        //反序列化-person
        try {
            //打开序列化文件
            FileInputStream fileInputStream = new FileInputStream("D:/class/test/test.txt");
            //反序列化
            ObjectInputStream objectInputStream = new ObjectInputStream(fileInputStream);
            //读取文件
           Person gtk0 = (Person) objectInputStream.readObject();
            //用户提示
            System.out.println("反序列化成功！！！");
            //输出反序列化后的结果
            System.out.println(gtk0.toString());
        //捕获在 try 块中可能发生的任何异常
        }catch (Exception e){
            //打印异常信息
            e.printStackTrace();
        }
    }
}
